package com.fitc.treestructure;

/*
 * Copyright (C) 2007-2012 by Brett Alistair Kromkamp <brett@polishedcode.com>.
 */

import java.util.ArrayList;

public class Node {
	public static int INDEX = -1; 
	
	
	public static final String ROOT = "";
    private String _identifier;
    private int _index;
    private boolean _visited;
    private ArrayList<Integer> _forwardPointers;
    private int _letterDepth;
    private int _parentPointer = -1; //default -1 = no parent (root)
    // constructor
    
    
    public Node(String identifier) {
        _identifier = identifier;
        _forwardPointers = new ArrayList<Integer>();
        
        //increment class index and set as instance index
        INDEX++;
        setIndex();
    }

    // properties
    public String getIdentifier() {
        return _identifier;
    }
    
    public void setVisited(boolean v){
    	_visited = v;
    }
    
    public int getLetterDepth(){
    	return _letterDepth;
    }
    
    public void setLetterDepth(int l){
    	_letterDepth = l;;
    }
    
    public boolean getVisited(){
    	return _visited;
    }

    public ArrayList<Integer> getForwardPointers() {
        return _forwardPointers;
    }

    // public interface - getters and setters
    public void addForwardPointer(int index) {
        _forwardPointers.add(index);
    }

	public void setParentPointer(int parentIndex) {
		_parentPointer = parentIndex;
	}
	public int getParentPointer() {
		return _parentPointer;
	}

	public void setIndex(){
		_index = INDEX;
	}
	
	public int getIndex(){
		return _index;
	}
	
	//helper methods
	public boolean hasParent() {
		// TODO Auto-generated method stub
		if (_parentPointer!=-1) return true;
		return false;
	}
	
	@Override
	public String toString(){
		return this.getIdentifier();
	}
}